const path = require('path')
const webpack = require('webpack')
const TerserWebpackPlugin = require('terser-webpack-plugin')

const dllPath = 'public/vue'

module.exports = {
  entry: {
    vue: ['vue', 'vue-router', 'axios', 'vuex', 'element-ui']
  },
  output: {
    path: path.resolve(__dirname, dllPath),
    filename: '[name].dll.js',
    library: '[name]_[hash]'
  },
  optimization: {
    minimizer: [
      new TerserWebpackPlugin({
        terserOptions: {
          output: {
            comments: false
          }
        },
        extractComments: false
      })
    ]
  },
  plugins: [
    new webpack.DllPlugin({
      path: path.join(__dirname, dllPath, '[name]-manifest.json'),
      name: '[name]_[hash]',
      context: process.cwd()
    })
  ],
  mode: 'production'
}
